package com.solotiger.geographic.ui.view;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.solotiger.geographic.R;
import com.solotiger.geographic.biz.model.Album;

public class AlbumHolderView extends FrameLayout {

    private Context mContext;

    private SimpleDraweeView mIvImage;

    private TextView mTvTitle;

    /**
     * 构造方法
     *
     * @param context
     */
    public AlbumHolderView(Context context) {
        super(context);
        mContext = context;
        LayoutInflater.from(mContext).inflate(R.layout.item_album_view, this, true);
    }

    /**
     * 设置数据
     *
     * @param album
     */
    public void setData(Album album) {
        if (mIvImage == null) {
            mIvImage = (SimpleDraweeView)findViewById(R.id.image);
            mTvTitle = findViewById(R.id.title);
        }
        mTvTitle.setText(album.getTitle());
        Uri uri = Uri.parse(album.getUrl());
        mIvImage.setImageURI(uri);

    }
}
